@extends('layouts.admin.application')

@section('css')
    <link rel="stylesheet" href="/vendor/daterangepicker/daterangepicker.css">
@endsection

@section('content')

    <div class="admin-content">

        <div class="am-cf am-padding">
            <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">赠送优惠券</strong> /
                <small>Create</small>
            </div>
        </div>
        <hr>
        @include('admin._flash')

        <div class="am-g">
            <div class="am-u-sm-12 am-u-md-12">

                <form class="am-form" action="/admin/checkPresent" method="post">
                    {{ csrf_field() }}
                  <input type="hidden" name="oncustomer_id" value="{{$userInfo->id}}"/>
                    <div class="am-g am-margin-top">
                        <div class="am-u-sm-4 am-u-md-2 am-text-right">
                            用户姓名：
                        </div>
                        <div class="am-u-sm-8 am-u-md-4">
                            {{$userInfo->name}}
                        </div>
                        <div class="am-hide-sm-only am-u-md-6"></div>
                    </div>

                    <div class="am-g am-margin-top">
                        <div class="am-u-sm-4 am-u-md-2 am-text-right">
                            用户手机号：
                        </div>
                        <div class="am-u-sm-8 am-u-md-4">
                            {{$userInfo->tel}}
                        </div>
                        <div class="am-hide-sm-only am-u-md-6"></div>
                    </div>
                    <div class="am-g am-margin-top">
                        <div class="am-u-sm-4 am-u-md-2 am-text-right">
                            选择优惠券：
                        </div>
                        <div class="am-u-sm-8 am-u-md-4 am-u-end col-end">
                            <select  data-am-selected="{btnWidth: '100%',  btnStyle: 'secondary', btnSize: 'sm', maxHeight: 360, searchBox: 1}"
                                     name="coupon_id">
                                <option value="">请选择</option>
                                  @foreach($couponArr as  $k=> $coupon)
                                    <option value="{{$coupon->id}}">

                                        {{$coupon['store']['name']}}


                                        {{$coupon->ratio}}折
                                      (<b>
                                        @foreach($coupon->types as $t)
                                            <label class="am-btn am-btn-danger am-btn-xs am-radius">
                                                {{$t->name}}
                                            </label>
                                        @endforeach
                                      </b>)


                                        {{$coupon->start_at}} ~ {{$coupon->end_at}}

                                    </option>
                                  @endforeach
                            </select>
                        </div>
                    </div>


                    <div class="am-g am-margin-top sort">
                        <div class="am-u-sm-4 am-u-md-2 am-text-right">
                            赠送张数
                        </div>
                        <div class="am-u-sm-8 am-u-md-4 am-u-end col-end">
                            <input type="text" name="coupon_num" class="am-input-sm" value="">
                        </div>
                        <div class="am-hide-sm-only am-u-md-6">如：赠送3张填写3</div>
                    </div>
                    {{--<div class="am-g am-margin-top sort">--}}
                    {{--<div class="am-u-sm-4 am-u-md-2 am-text-right">--}}
                    {{--结束时间--}}
                    {{--</div>--}}
                    {{--<div class="am-u-sm-8 am-u-md-4 am-u-end col-end">--}}
                    {{--<input type="text" name="sort_order" class="am-input-sm" value="" placeholder="点击选择结束时间" >--}}
                    {{--</div>--}}
                    {{--</div>--}}










                    <div class="am-margin">
                        <button type="submit" class="am-btn am-btn-primary am-radius">确认赠送</button>
                    </div>
                </form>
            </div>
        </div>
    </div>


@endsection
@section('js')
    <script src="/vendor/daterangepicker/moment.js"></script>
    <script src="/vendor/moment/locale/zh-cn.js"></script>
    <script src="/vendor/daterangepicker/daterangepicker.js"></script>

    <script>
        $(function () {
            //时间插件
            $('#date_start').daterangepicker({

                "autoUpdateInput": false,
                "autoApply": true,
                "locale": {
                    "format": "YYYY-MM-DD",
                    "applyLabel": "确定",
                    "cancelLabel": "取消"
                }
            }, function (start, end, label) {
                this.element[0].value = start.format('YYYY-MM-DD') + ' ~ ' + end.format('YYYY-MM-DD');
            });
        });

    </script>
@endsection